module GalleryHelper
  #This method writes Tags for a photo along with links to similar photos
  def writeTags(tags)
    tagList = ''
    if !tags.nil? && !tags.empty?
      tagList = 'Tags: '
      tags.each do |tag|
        tagList += link_to(tag.raw,{:controller => "tags",:action => "list",:id => tag.raw})+' '
      end
    else
      tagList += 'Tags: <i>None</i>'
    end
    return tagList
  end
  #This method writes a section that allows bookmarking of a photo
  #Supported sites are Diggit, del.icio.us, reddit and Technorati
  def writeSocialBookmarks(id,title)
    title = title.gsub(" ","+")
    url = url_for(:controller=>"gallery",:action=>"list",:id=>id,:only_path=>false)
    return 'Bookmark: ' + writeDiggIt(url,title)+' '+writeDelicious(url,title)+' '+writeReddit(url,title)+' '+writeTechnorati(url)+' '
  end
  #This method returns a link to bookmark the current photo at diggit
  def writeDiggIt(url,title)
    return '<a href=''http://digg.com/submit?phase=2&url='+url+'&title='+title+''' title=''Digg'' ><img src=''/images/digg.png'' alt=''Digg'' title=''Digg'' border=''0''></a>'
  end
  #This method returns a link to bookmark the current photo at del.icio.us
  def writeDelicious(url,title)
    return '<a href=''http://del.icio.us/post?url='+url+'&title='+title+''' title=''Delicious'' ><img src=''/images/delicious.png'' alt=''del.icio.us'' title=''del.icio.us'' border=''0''></a>'
  end
  #This method returns a link to bookmark the current photo at reddit
  def writeReddit(url,title)
    return '<a href=''http://reddit.com/submit?url='+url+'&title='+title+''' title=''Reddit'' ><img src=''/images/reddit.png'' alt=''Reddit'' title=''Reddit'' border=''0''></a>'
  end
  #This method returns a link to bookmark the current photo at technorati
  def writeTechnorati(url)
    return '<a href=''http://technorati.com/faves?add='+url+' title=''Technorati'' ><img src=''/images/technorati.png'' alt=''Technorati'' title=''Technorati'' border=''0''></a>'
  end
end
